/*
 * kylin-os-manager
 *
 * Copyright (C) 2022, KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef DNSCHECKTHREAD_H
#define DNSCHECKTHREAD_H

#include <QObject>
#include <QProcess>
#include "libBase.h"
#include "nw_check_tool_lib.h"

class DnsCheckThread : public QObject
{
    Q_OBJECT
public:
    explicit DnsCheckThread(QObject *parent = nullptr);

private:
    bool m_hasDNS = false;
    NWCheckToolLib *m_checkTool = nullptr;
    QProcess *m_cmdProc = nullptr;
    InnerNetCheck m_settings;
    QString m_webSite;
    statusStruct m_cur;
    bool isContinue = true;
signals:
    void sigDnsCheckIsOver(statusStruct cur);
    void sigCheckIsOver(CHECKRESULT result);

private slots:
    void readCmdBashInfo();
    void readCmdBashInfoMore();
    void getDNSCheckResult(const QString &web);
    void getDNSCheckResult(const QList<QString> &list, int len);
    void slotCheckIsOver(CHECKRESULT result);
    void slotProcessOccurError();

public slots:
    void slotDnsCheckStart(InnerNetCheck &checkSettings);
};

#endif // DNSCHECKTHREAD_H
